<cfscript>
    view = createObject("component", session.rootDir & ".views.layout");   
    view.init("Status Report","","","Status",index);
    view.html(); 
</cfscript>


<cffunction name="index" access="public" output="true" returntype="any">
	<cfscript>
	import models.*;
	
	Step = ORMExecuteQuery("FROM Steps WHERE StepsID = 2 OR StepsID = 3 OR StepsID = 4 OR StepsID = 5 OR StepsID = 6 OR StepsID = 7 OR StepsID = 16 ORDER BY OrderNo");
	stepSQL = "FROM StepActions WHERE StepsID = ? AND ActTimeStamp IS NULL";
	getEmployeeSQL = "FROM Employee WHERE EmployeeID = ? AND NonSCFTypeID IS NULL";
	getEmployeeNONSFCSQL = "FROM Employee WHERE EmployeeID = ? AND NonSCFTypeID IS NOT NULL";	
	</cfscript>
    
	<cfoutput>
    
    <h1 class="title">Status Report</h1>
    <div class="entry">
        Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
        The page details the Steps in the Creation process and lists the 
        number of employees staged at each.  <BR /> <BR />
        
        <cfform name="status" method="post" action="">
        
		<table align="center">
		    <cfloop from="1" to="#ArrayLen(Step)#" index="i">
		    
		        <cfset StepActions = ORMExecuteQuery(stepSQL, [Step[i].getStepsID()] ) />
		        
		        <tr>
		            <td valign="top" colspan="3">
		                <span class="tableHeader">
		                    #Step[i].getStepDesc()# (#ArrayLen(StepActions)#)
		                </span>     
		            </td>
		        </tr>
		        <tr>
		            <td width="25">&nbsp;
		                
		            </td>
		            <td valign="top"> 
		                <table>
		                    <tr>
		                        <td>
		                            <strong>
                                        <cfif (Session.strAuthType EQ Step[i].getAppGroup() OR Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) AND Step[i].getPage_Home() NEQ "">
		                                  #( ArrayLen(StepActions) GT 0 ? '<a href="SCF/#Step[i].getController()#">SCF EMPLOYEES</a>' : 'SCF EMPLOYEES')#
                                        <cfelse>
                                            SCF EMPLOYEES
                                        </cfif>
		                            </strong>     
		                        </td>
		                    </tr>
		                    <cfif ArrayLen(StepActions) GT 0>
		                        <cfloop array="#StepActions#" index="ii"> 
		                        
		                            <cfset Employee = ORMExecuteQuery(getEmployeeSQL, [ii.getEmployeeID()], true ) />
                                    <cfif isDefined("Employee")>
					                    <tr>                  
					                        <td>					                            
					                            <a href="SCF/#Step[i].getController()#?StepID=#ii.getStepActionsID()#">
					                                #Employee.getLastName() & ", " & Employee.getFirstName()#
					                            </a>					                            
					                        </td>
					                    </tr>
                                    </cfif>
		                        </cfloop>
		                    <cfelse>
			                    <tr>           
			                        <td>
			                            <span class="error">At the present time, there are not any employees staged for this step.</span>
			                        </td>
			                    </tr>
		                    </cfif>
		                </table>
		            </td>
		            <td valign="top"> 
		                <table>
		                    <tr>            
		                        <td>
		                            <strong>
                                        <cfif (Session.strAuthType EQ Step[i].getAppGroup() OR Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) and Step[i].getPage_UserDirect() NEQ ''>
                                            #( ArrayLen(StepActions) ? '<a href="NonSCF/#Step[i].getController()#">CONTRACTORS</a>' : 'CONTRACTORS')#
                                        <cfelse>
                                            CONTRACTORS
                                        </cfif>                                    
		                            </strong>
		                        </td>
		                    </tr>
		                    <cfif ArrayLen(StepActions) GT 0>
		                        <cfloop array="#StepActions#" index="ii">
		                         
		                            <cfset EmployeeNonSCF = ORMExecuteQuery(getEmployeeNONSFCSQL, [ii.getEmployeeID()], true ) />
                                    <cfif isDefined("EmployeeNonSCF")>
					                    <tr>                  
					                        <td>					                            
				                                <a href="NonSCF/#Step[i].getController()#?StepID=#ii.getStepActionsID()#">
				                                   #EmployeeNonSCF.getLastName() & ", " & EmployeeNonSCF.getFirstName()#
				                                </a>					                            
					                        </td>
					                    </tr>
                                    </cfif>
		                        </cfloop>
		                    <cfelse>
			                    <tr>       
			                        <td>
			                            <span class="error">At the present time, there are not any contractors staged for this step.</span>
			                        </td>
			                    </tr>
		                    </cfif>
		                </table>
		            </td>
		        </tr>
		        <tr>           
		            <td>&nbsp;</td>
		        </tr>
		    </cfloop>
		</table>
        </cfform>
    </div>
	</cfoutput>
</cffunction>